
#include "EventListQueue.h"
#include <iostream>

EventListQueue::EventListQueue()
{
}
bool EventListQueue::DoQueueQuit()
{
	m_event.Set();
	return true;
}
EventListQueue::~EventListQueue()
{
	event_list.clear();
}

bool EventListQueue::enQueue(const EventList & event_l)
{
	{
		base::AutoLock Locker(mutex);
		event_list.push_back(event_l);
	}
	
	m_event.Set();
	return true;
}

bool EventListQueue::deQueue(EventList&  event_l, bool block)
{
	bool ret = false;
	m_event.TryWait(3000);


	base::AutoLock Locker(mutex);
	if (!event_list.empty())
	{
		event_l = event_list.front();

		event_list.pop_front();
		ret = true;
	}
	return ret;
}